package priv.wjh.study.cloud.mock.feign;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import priv.wjh.study.cloud.feign.api.StudyFeignApi;
import priv.wjh.study.cloud.feign.api.ao.BaseAo;
import priv.wjh.study.cloud.feign.api.ao.TestOneAo;
import priv.wjh.study.cloud.feign.api.ao.TestTweAo;

/**
 * //TODO
 *
 * @author wangjunhao
 **/
@Slf4j
@EnableFeignClients(basePackages = {"priv.wjh.study.cloud.feign.api", "priv.wjh.study.cloud.mock.feign"})
@EnableDiscoveryClient
@SpringBootApplication()
public class FeignMockApplication implements ApplicationRunner {
    public static void main(String[] args) {
        SpringApplication.run(FeignMockApplication.class, args);
    }

    @Autowired
    private StudyFeignApi studyFeignApi;


    @Override
    public void run(ApplicationArguments args) throws Exception {
//        Mockito.when(studyFeignApi.test()).thenReturn("1111111");
//        log.info(studyFeignApi.test());
//        MyTestVo myTestVo1 = studyFeignApi.test2();

        TestOneAo ao = new TestOneAo();
        studyFeignApi.genericTest(ao);

        TestTweAo ao1 = new TestTweAo();
        studyFeignApi.genericTest(ao1);


        BaseAo baseAo = new BaseAo();
        try {
            studyFeignApi.genericTest(baseAo);
        } catch (Exception e) {
            log.info("exception: ", e);
        }

        BaseAo ao2 = studyFeignApi.getAo(1);
        BaseAo ao3 = studyFeignApi.getAo(2);

        log.info(ao2.toString());
        log.info(ao3.toString());

    }


}
